package com.coscon.service.patternCommon.impl.mouse;

import com.coscon.model.IrcaCmd;
import com.coscon.service.patternCommon.ICommand;
import org.apache.commons.lang3.StringUtils;

import javax.websocket.Session;
import java.awt.*;

/**
 * 滚轴
 */
public class MouseRollerCmdImpl implements ICommand {

    private Robot rb;

    public MouseRollerCmdImpl(Robot rb){
        this.rb = rb;
    }
    

    public Boolean execute(IrcaCmd cmd,  Session session) {
        if(StringUtils.equalsIgnoreCase(cmd.getValue(),"UP" )){//鼠标滚轴向上
            this.rb.mouseWheel(3);
        }else if(StringUtils.equalsIgnoreCase(cmd.getValue(),"DOWN" )){//鼠标滚轴向下
            this.rb.mouseWheel(-3);
        }
        return true;
    }

    @Override
    public Boolean executeByMac(IrcaCmd cmd, Session session) {
        return this.execute(cmd,session);
    }

    @Override
    public Boolean executeByWin(IrcaCmd cmd, Session session) {
        return this.execute(cmd,session);
    }

    @Override
    public Boolean executeByLinux(IrcaCmd cmd, Session session) {
        return this.execute(cmd,session);
    }

}
